//@author A0080442N
#pragma once
#ifndef DATE_H_
#define DATE_H_

#include "TaskItGlobal.h"
#include <ctime>

//Date class for TaskIt. Other than storing int values of day, month and year,
//the class can check whether 2 dates are the same or one is later than the other.
//It is also possible to increment decrement current date by a specific number of days.
class Date {
private:
	int _day, _month, _year;
	int _dayOfWeek; //Takes value between 1 and 7, where Monday is 1 and Sunday is 7.
	string _display;
	bool _hasDate;
	
	void setDisplay();

public:
	Date();
	
	//Given an integer, the function set the date into the private attributes
	//_day, _month and _year.
	//Pre-Req: Takes in an integer. Valid inputs should be DMMYY or DDMMYY.
	//Post-Req: Sets the date if the integer is valid, else throws an invalid message.
	void setDate(int date);
	//Sets this date to the local date on the computer and identifies which day
	//of the week it is.
	//Pre-Req: None. 
	//Post-Req: _day, _month, _year will be set to local date on computer and _dayOfWeek will
	//          reflect the day.
	void setLocalDate();
	
	//Given an integer, checks whether it follows the format of DMMYY or DDMMYY.
	//It takes into account number of days in a month and leap years.
	//Pre-Req: An integer value.
	//Post-Req: Returns true if the integer is valid and follows the format.
	bool isValidDate(int date);
	//Given a second date, it checks whether the date is the same date as the current date.
	//Pre-Req: A second date.
	//Post-Req: Returns true if each of the _day, _month and _year is equal.
	bool isSameDate(Date secondDate);
	//Given a second date, it checks whether the current date is later than the
	//second date.
	//Pre-Req: A second date.
	//Post-Req: Returns true if current date is later than the second date 
	//			and false when the reverse is true, if both has dates.
	//			Other case to consider:
	//			1) A date class which contains a valid date will always be considered as later
	//			   than one without a valid date.
	//			2) If both dates do not contain a valid date, function will return false.
	bool isLaterDate(Date secondDate);
	
	//This is the getter function to get the string _display.
	//Pre-Req: None.
	//Post-Req: Returns the string _display.
	string getDisplay();

	//This is the getter function to get the int _day.
	//Pre-Req: None.
	//Post-Req: Returns the int _day.
	int getDay();
	//This is the getter function to get the int _month.
	//Pre-Req: None.
	//Post-Req: Returns the int _month.
	int getMonth();
	//This is the getter function to get the int _year.
	//Pre-Req: None.
	//Post-Req: Returns the int _year.
	int getYear();
	//This is the getter function to get the int _dayOfWeek.
	//Pre-Req: None.
	//Post-Req: Returns the int _dayOfWeek which ranges from 1 to 7.
	int getDayOfWeek();
	//This is the getter function to get the boolean _hasDate.
	//Pre-Req: None.
	//Post-Req: Returns the boolean _hasDate.
	bool getHasDate();
	
	//Given an additional number of days, add that particular number of days
	//to the current date.
	//Pre-Req: A valid date and the number of days to add.
	//Post-Req: Current date will be modified after adding the given number of days.
	void addNumberofDays(int numDays);
	//Given a number of days, decrease current date by that particular
	//number of days.
	//Pre-Req: A valid date and the number of days to minus.
	//Post-Req: Current date will be modified after decreasing the given number of days.
	void minusNumberofDays(int numDays);
};

#endif